# koroFileHeader at Home PC
# Create: 2021-01-01 19:35:26
# LastEdit: 2021-01-01 21:04:09
"""https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/"""
__author__ = '749B'

from typing import List

class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        shift = 0
        for i in range(1, len(nums)):
            if nums[i-1-shift] == nums[i]:
                shift += 1
                continue
            if shift:
                nums[i-shift] = nums[i]
        return len(nums) - shift



